﻿<UserControls:ScrumUserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.View.ProjectPlanningIterations"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:Microsoft.Surface.Presentation.Controls;assembly=Microsoft.Surface.Presentation"    
    xmlns:ViewModel="clr-namespace:ScrumTable.UI.ViewModel;assembly=ScrumTable.UI.ViewModel"    
    xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls"
                               Presentation:SurfaceDragDrop.Drop="OnDropProject" 
                               xmlns:Presentation="clr-namespace:Microsoft.Surface.Presentation;assembly=Microsoft.Surface.Presentation"
                               x:Name="ControlRoot" >
    <Grid >
        <Grid.Resources>
            <Converter:DateTimeConverter x:Key="DateTimeConverter"/>
            <Converter:CalcConverter CalcType="Add" ValueRight="50" x:Key="AddMargin"/>
            <Converter:ConverterIterationBackGround x:Key="IterationBackground" BackgroundName="ListBoxBackground"/>
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="0.8*"></RowDefinition>
            <RowDefinition Height="0.2*"></RowDefinition>
        </Grid.RowDefinitions>

        <Label x:Name="lblNone" FontSize="60" FontWeight="Bold" Content="{Binding ProjectName}" Opacity="0.25" AllowDrop="False" IsHitTestVisible="False" Panel.ZIndex="1" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
        <Controls:SurfaceScrollViewer VerticalScrollBarVisibility="Disabled" x:Name="IterationScrollViewer" BorderBrush="#AFAFAF" BorderThickness="1" Background="White">
            <ItemsControl ScrollViewer.HorizontalScrollBarVisibility="Visible"  BorderThickness="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="IterationsList"
            ItemsSource="{Binding Path=Iterations}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel IsItemsHost="True" Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <StackPanel Orientation="Horizontal" Opacity="1" AllowDrop="False" IsHitTestVisible="False" Panel.ZIndex="1">
                                <StackPanel.LayoutTransform>
                                    <RotateTransform Angle="90"/>
                                </StackPanel.LayoutTransform>

                                <Grid VerticalAlignment="Top" Width="30" Height="30" Margin="5">
                                    <Grid.LayoutTransform>
                                        <RotateTransform Angle="-90" />
                                    </Grid.LayoutTransform>
                                    <UserControls:StarControl VerticalAlignment="Top" StrokeBrush="Black" FillBrush="White"/>
                                    <Label FontWeight="Bold" Content="{Binding TotalStoryPoints}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                </Grid>
                                <Label FontSize="20" Content="{Binding Name}"  />                                
                                <Label FontSize="15" Content="{Binding StartTime, Converter={StaticResource DateTimeConverter}}" />
                                <Label FontSize="15" Content=" - " />
                                <Label FontSize="15" Content="{Binding EndTime,  Converter={StaticResource DateTimeConverter}}" />
                                
                            </StackPanel>
                            <UserControls:SurfaceDragDropListBox Width="{Binding ElementName=ControlRoot, Path=DataContext.ScrumData.ConfigManager.Config.ControlSize.X, Converter={StaticResource AddMargin}}" 
                                                                 Presentation:SurfaceDragDrop.Drop="OnDrop" 
                                                                 IsItemSelectable="False" AllowDrop="True" VerticalAlignment="Stretch" CanDragDrop="{Binding CanItemDrop, ElementName=ControlRoot}"                                                                  
                                                                 ItemsSource="{Binding ItemsOnIteration}" Background="{Binding Converter={StaticResource IterationBackground}}" >
                                <UserControls:SurfaceDragDropListBox.ItemTemplate>
                                    <DataTemplate>
                                        <UserControls:ScrumItemControl HorizontalAlignment="Center" DataContext="{Binding}"/>
                                    </DataTemplate>
                                </UserControls:SurfaceDragDropListBox.ItemTemplate>
                            </UserControls:SurfaceDragDropListBox>
                        </Grid>
                    </DataTemplate>
                    </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Controls:SurfaceScrollViewer>



        <UserControls:SurfaceDragDropListBox x:Name="ProjectUserStories" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="3" 
          Presentation:SurfaceDragDrop.Drop="OnDrop" 
            AllowDrop="True" IsItemSelectable="False" CanDragDrop="{Binding CanItemDrop, ElementName=ControlRoot}" 
            Orientation="Horizontal"
            MultipleColumnsRows="True" 
            ItemsSource="{Binding Path=ProjectItems}"  >
            <UserControls:SurfaceDragDropListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <UserControls:ScrumItemControl DataContext="{Binding}" />
                    </StackPanel>
                </DataTemplate>
            </UserControls:SurfaceDragDropListBox.ItemTemplate>
        </UserControls:SurfaceDragDropListBox>

    </Grid>
</UserControls:ScrumUserControl>
